Import
This hook replaces the useGetSwapPrices hook which was removed in v5.2.3.
Usage
Return Type: UseQueryResult<LifiSwapRoute[]>
The hook returns all properties from React Query’s UseQueryResult with swap routes data. Here’s the detailed structure of the LifiSwapRoute object:
Properties
data
LifiSwapRoute[] | undefined
Array of swap route objects containing:
route
fromChainId: The chain ID of the token to sell
toChainId: The chain ID of the token to buy
fromTokens: Array of tokens that can be used to pay for the swap
toTokens: Array of tokens that can be received from the swap
isLoading
boolean
Loading state for the data fetch.
isError
boolean
Error state indicating if the query failed.
error
Error | null
Any error that occurred during data fetching.
Parameters
The hook accepts two parameters:
args: UseGetSwapRoutesArgs
options: HooksOptions
Additional Notes
- This hook uses React Query to fetch and cache swap routes from the Sequence API.
- Stale time is set to one hour by default to avoid refreshing quotes while the user is completing transactions.
- This hook will not return “fromTokens” that the user does not have in their wallet.